import request from '@/utils/request'

const basePath = '/jpower-system'

/**
 * @description: 查询行政区域
 * @param {*} params
 * @return {*}
 */
export function getList(params) {
  return request({
    url: basePath + '/core/city/listPage',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 懒加载树型菜单
 * @param {*} pcode
 * @return {*}
 */
export function getTree(pcode) {
  return request({
    url: basePath + '/core/city/lazyTree',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { pcode }
  })
}

/**
 * @description: 新增行政区域
 * @param {*} params
 * @return {*}
 */
export function saveArea(params) {
  return request({
    url: basePath + '/core/city/add',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 删除行政区域
 * @param {*} ids
 * @return {*}
 */
export function removeArea(ids) {
  return request({
    url: basePath + '/core/city/delete',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params: { ids }
  })
}

/**
 * @description: 更新行政区域
 * @param {*} ids
 * @return {*}
 */
export function uploadeArea(params) {
  return request({
    url: basePath + '/core/city/update',
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * @description: 获取下级列表
 * @param {pcode，name} params
 * @return {*}
 */
export function getChildList(params) {
  return request({
    url: basePath + '/core/city/listChild',
    method: 'get',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}
